export default function (method, config) {
  let ThrottlingTime = '';
  let Context = {};
  let Data = {};
  if (config.constructor === Number) {
    ThrottlingTime = config;
  } else {
    let {
      throttlingTime,
      context,
      data,
    } = config;
    ThrottlingTime = throttlingTime;
    Context = context;
    Data = data;
  }
  if (typeof method.tId === 'undefined') {
    method.tId = 0;
    method.call(Context, Data);
    return;
  }
  let tId = method.tId;
  if (!tId) {
    method.tId = setTimeout(function () {
      method.call(Context, Data);
      delete method.tId;
    }, ThrottlingTime || 500);
  }
};
